 //========================================================================
// *作者：海盗猫  主页：ilplay.com
// *脚本：EditorGUILayout
// *描述：通用样式脚本
// *?2021 MYJL . All rights reserved.
//* ======================================================================
using UnityEngine;

namespace HDMCode.UIFrameEditor
{
    public class EditorGUILayout
    {
        public Rect DefaultRect { get; set; }

        public float Width { get; set; }

        public float Padding { get; set; } = 10;

        private float m_IndexWidth { get; set; } = 30;

        private float m_TargetWidth => (Width - m_IndexWidth - Padding) / 3;

        private float m_ComponentsWidth => m_TargetWidth * 2;

        public EditorGUILayout(Rect defaultRect, float width)
        {
            this.DefaultRect = defaultRect;
            this.Width = width;
        }

        public Rect IndexRect => new Rect(DefaultRect.x, DefaultRect.y, m_IndexWidth, DefaultRect.height);
        public Rect TargetRect => new Rect(DefaultRect.x + Padding + m_IndexWidth, DefaultRect.y, m_TargetWidth, DefaultRect.height);
        public Rect ComponentsRect => new Rect(DefaultRect.x + Padding * 2 + m_IndexWidth + m_TargetWidth, DefaultRect.y, m_ComponentsWidth - Padding, DefaultRect.height);


        /// <summary>
        /// 创建通用标题
        /// </summary>
        public static void CreatTile()
        {
            GUI.color = new Color(255, 129, 203);
            GUILayout.Space(10);
            GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(2));
            GUILayout.Box("UI管理框架-海盗猫", new[] { GUILayout.ExpandWidth(true), GUILayout.ExpandWidth(true) });
            GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(2));
            GUI.color = Color.white;
            UnityEditor.EditorGUILayout.Space();
        }
    }
}
